package org.thoughtworks.selenium.flex.driver;

public class Command {

    protected String commandName;
    protected CommandArguments commandArguments;

    public Command(String commandName, Object... commandArguments) {
        this.commandName = commandName;
        this.commandArguments = new CommandArguments(commandArguments);
    }

    protected class CommandArguments {
        private static final String ARG_SEPERATOR = "_ARG_SEP_";
        private Object[] commandArguments;

        public CommandArguments(Object... commandArguments) {
            this.commandArguments = commandArguments;
        }

        public String join() {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < commandArguments.length; i++) {
                sb.append(commandArguments[i].toString());
                if (i < commandArguments.length - 1 && commandArguments.length > 1)
                    sb.append(ARG_SEPERATOR);
            }
            return sb.toString();
        }
    }
}
